package j.framework.tags.form;

import javax.servlet.jsp.JspException;

/**
 * 输入框tag之Number
 * User: jason
 * Date: 2014/11/7 17:13
 */
public class NumberTag extends BaseInputTag {

    private Integer min;
    private Integer max;

    @Override
    public String getInputType() {
        setImeDisabled(true);
        return "number";
    }

    @Override
    public void writeInputTagValue(FormTagWriter writer, Object value)  throws JspException {
        if(null == value){
            value = getFormDataValue();
        }
        if(null!=value){
            writer.writeFormTagProperty("value",value.toString());
        }
    }

    @Override
    public void writeFormTagProperties(FormTagWriter writer) throws JspException {
        super.writeFormTagProperties(writer);
        if(null!=min){
            writer.writeFormTagProperty("min",min.toString());
        }
        if(null!=max){
            writer.writeFormTagProperty("max",max.toString());
        }
    }

    @Override
    public String getCssClassName() {
        return "";
    }

    public void setMin(Integer min) {
        this.min = min;
    }

    public void setMax(Integer max) {
        this.max = max;
    }
}
